﻿/*
 *Copyright(C) 2021 by  GYYX All rights reserved.
 *Unity版本：2018.4.23f1 
 *作者:程一峰  
 *创建日期: 2021-05-06 
 *模块说明：
 *版本: 1.2
*/


using UnityEditor;
using UnityEngine;
using Warfare.FSM;

namespace WarfareEditor.FSM
{
    /// <summary>
    /// 左侧的节点信息编辑区域
    /// </summary>
    public class FSMZoom_NodeEdit : FSMZoom
    {
        protected internal override void OnDestroy() { }
        private FSMAsset CurrentAsset { get { return window.CurrentAsset; } }

        private FSMNode CurrentNode { get { return window.CurrentNode; } }

        protected internal override void OnGUI()
        {
            if (CurrentAsset == null)
                return;

            EditorGUILayout.BeginVertical("box");
            GUILayout.Space(5);

            if (CurrentNode != null)
            {
                //当前选择的节点；
                EditorGUILayout.LabelField($"类型：{CurrentNode.GetType()}");
                EditorGUILayout.LabelField($"节点名：{CurrentNode.NodeName}");

#if UNITY_EDITOR
                EditorGUILayout.LabelField($"说明：{CurrentNode.NodeDescripe}。");
                EditorGUILayout.LabelField($"成功条件：{CurrentNode.NodeSucessCondition}。");
                EditorGUILayout.LabelField($"失败条件：{CurrentNode.NodeFailedCondition}。");
#endif

                if (CurrentNode is FSMRootNode)
                    //根节点不能编辑；
                    EditorGUILayout.LabelField("根节点不能进行编辑！");
                else if (GUILayout.Button("编辑"))
                    //编辑单个节点的按钮
                    FSMNodeEditorWindow.ShowWindow(CurrentNode);
            }
            EditorGUILayout.EndVertical();
        }

    }
}